﻿module Sustainalytics.EsgRatings {

    export class EsgControversyIndicatorService implements IEsgControversyIndicatorService {

        constructor(
            private $http: ng.IHttpService,
            private $q: ng.IQService) {
        }

        public get(companyId: string): ng.IPromise<EsgControversyIndicatorDto[]> {
            var ctx = this;

            var url = '/esgratingserv/api/v1/company/' + companyId + '/esgControversyIndicator';

            var promise = ctx.$http.get(url);

            var def = ctx.$q.defer();
            promise.then(
                // success
                function (res) {
                    def.resolve(res.data);
                },
                // error
                function (reason) {
                    def.reject(reason);
                });

            return def.promise;
        }
    }


    angular.module(esgRatingsModuleName).service('EsgControversyIndicatorService', EsgControversyIndicatorService);
} 